//document.oncontextmenu=new Function("event.returnValue=false");
//document.onselectstart=new Function("event.returnValue=false");
//document.oncontextmenu=function(e){return false;}
//$(document.body).css('-moz-user-select', 'none');
 



Date.prototype.format = function(format){
    var o = {
        "M+" : this.getMonth()+1, //month
        "d+" : this.getDate(), //day
        "h+" : this.getHours(), //hour
        "m+" : this.getMinutes(), //minute
        "s+" : this.getSeconds(), //second
        "q+" : Math.floor((this.getMonth()+3)/3), //quarter
        "S" : this.getMilliseconds() //millisecond
    }

    if(/(y+)/.test(format)) {
        format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
    }

    for(var k in o) {
        if(new RegExp("("+ k +")").test(format)) {
            format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
        }
    }
    return format;
}

function displayView(content_analysis,nav_second_level){
    console.log("xianshi ",showTable,showDetailInfo)
    for(var i in showTable){
        $('#' + showTable[i]).css('display', 'block');
        if(showTable[i] == content_analysis){
            $('#' + content_analysis).addClass("active")
        }
    }

    for(var i in showDetailInfo){
        $('#' + showDetailInfo[i]).css('display', 'block');
        if(showDetailInfo[i] == nav_second_level){
            $('#' + nav_second_level).addClass("active")
        }
    }
}


function show_query_hint(query_hint){
    var query_hint = document.getElementById(query_hint);
    query_hint.style.display="block";
}

function undisplay(id){
    if($("#" + id).css('display') == 'none'){
        $("#" + id).css('display', 'block')
        $("#undisplay").text("隐藏")
    }else{
        $("#" + id).css('display', 'none')
        $("#undisplay").text("展开")
    }
}

function undisplayCo(id){
    if($("#" + id).css('display') == 'none'){
        $("#" + id).css('display', 'block')
        $("#undisplayCo").text("隐藏")
    }else{
        $("#" + id).css('display', 'none')
        $("#undisplayCo").text("展开")
    }
}

function queryHintCallback(query_hint){
    var query_hint = document.getElementById(query_hint);
    query_hint.style.display="none";
}


function createPage(pageSize, buttons, total,data_temp) {
    $(".pagination").empty();
    $('.pagination').Paging({
        pagesize: pageSize, count: total, toolbar: true, pageSizeList: [temp_page_size],
        callback: function (page, size, count) {
            page = page - 1;
            var temp_teble_info = data_temp.slice(page * size, page * pageSize + size);
            showTableInfo(temp_teble_info);
        }
    });
}

function changeTimeToString(time,flag){
    var time_temp = time;
    if(!time)
        return ;
    time = new Date(time);

    if(time == 'Invalid Date')
        return time_temp;

    var times;
    var year = time.getFullYear();
    var mon = time.getMonth() + 1;
    var day = time.getDate();
    var hour = time.getHours();
    var min = time.getMinutes();
    var sec = time.getSeconds();
    mon = mon < 10 ? '0' + mon : mon;
    day = day < 10 ? '0' + day : day;
    hour = hour < 10 ? '0' + hour : hour;
    min = min < 10 ? '0' + min : min;
    sec = sec < 10 ? '0' + sec : sec;
    if(flag)
        times = "" + year + "/" + mon + "/" +day;
    else
        times = "" + year + "/" + mon + "/" +day + " " + hour + ":" + min +  ":" + sec;
    return times;
}
/**
 *
 * @param url {String}
 * @param data {Object}
 * @param sucFn {Function}
 * @param errFn {Function}
 */


function httpAjax(url,data,sucFn,errFn){
    $.ajax({
        url:url,
        type:'post',
        dataType:'json',
        data:data,
        success:function(data){
            sucFn && sucFn(data);
        },
        error:function(msg){
            errFn && errFn(msg);
        }
    });
}